﻿
namespace Patterns4Net.Tests.Core.Patterns
{
    using System.Linq;
    using NUnit.Framework;
    using Patterns4Net.Core.CecilExtensions;
    using Patterns4Net.Core.Patterns;

    [TestFixture]
    public class VisitorTest
    {
        [Test]
        public void Elements_Property_Returns_Root_ChildA_And_ChildB()
        {
            var visitor = new Visitor(typeof(VisitorTest).GetTypeDefinition(), typeof(Root).GetTypeDefinition(), false);
            var elements = visitor.VisitableElements;

            CollectionAssert.AreEquivalent(
                new[] { typeof(Root).Name, typeof(ChildA).Name, typeof(ChildB).Name, typeof(ChildC).Name },
                elements.Select(x => x.Name));
        }

        public class Root
        {            
        }
 
        public class ChildA : Root
        {            
        }

        public class ChildB : Root
        {            
        }

        public class ChildC : ChildB
        {            
        }
    }
}
